package com.agent.service.impl;


import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.agent.mapper.AsLogsMapper;
import com.agent.pojo.AsLogs;
import com.agent.pojo.AsLogsExample;
import com.agent.service.AsLogsService;
import com.agent.util.PageResult;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
@Service
public class AsLogsServiceImpl implements AsLogsService{
	@Autowired
	private AsLogsMapper asLogsMapper;
	@Override
	public PageResult findAsLogsPage(int pageNum,int pageSize){
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, pageSize);
		AsLogsExample example=new AsLogsExample();
		example.setOrderByClause("operatedatetime desc");
		Page<AsLogs> page = (Page<AsLogs>) asLogsMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}
	@Override
	public void addLog(Long userid, String username, String operateinfo) {
		// TODO Auto-generated method stub
		AsLogs log=new AsLogs();
		log.setOperatedatetime(new Date());
		log.setOperateinfo(operateinfo);
		log.setUserid(userid);
		log.setUsername(username);
		asLogsMapper.insertSelective(log);
	}

}
